<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\balancediscount\controller;

class AdminCard extends \app\AdminRest
{
    protected $card_model;
    protected $coupon_model;
    public function __construct(\think\App $app)
    {
        parent::__construct($app);
        $this->card_model = new \app\balancediscount\model\Card();
    }
    public function cardSelect()
    {
        $input = $this->_param;
        $dis = ["uniacid" => $this->_uniacid, "status" => 1];
        $data = $this->card_model->where($dis)->order("top desc,id desc")->select()->toArray();
        return $this->success($data);
    }
    public function cardList()
    {
        $input = $this->_param;
        $dis[] = ["uniacid", "=", $this->_uniacid];
        $dis[] = ["status", ">", -1];
        $data = $this->card_model->dataList($dis, $input["limit"]);
        return $this->success($data);
    }
    public function cardAdd()
    {
        $input = $this->_input;
        $insert = ["uniacid" => $this->_uniacid, "discount" => $input["discount"], "title" => $input["title"], "price" => $input["price"], "month" => $input["month"], "status" => 1, "top" => $input["top"], "create_time" => time()];
        $res = $this->card_model->insert($insert);
        return $this->success($res);
    }
    public function cardUpdate()
    {
        $input = $this->_input;
        $dis = ["id" => $input["id"]];
        $insert = ["uniacid" => $this->_uniacid, "discount" => $input["discount"], "title" => $input["title"], "price" => $input["price"], "month" => $input["month"], "top" => $input["top"]];
        $res = $this->card_model->dataUpdate($dis, $insert);
        return $this->success($res);
    }
    public function cardInfo()
    {
        $input = $this->_param;
        $dis = ["id" => $input["id"]];
        $data = $this->card_model->dataInfo($dis);
        return $this->success($data);
    }
    public function cardStatusUpdate()
    {
        $input = $this->_input;
        $dis = ["id" => $input["id"]];
        $data = $this->card_model->dataUpdate($dis, ["status" => $input["status"]]);
        return $this->success($data);
    }
}

?>